﻿using System.Collections.Generic;
using System.Data;
using Smatime.Web.DAO.SmatimeDatasetTableAdapters;
using Smatime.Web.Models;

namespace Smatime.Web.DAO
{
    public class CompanyStaffTimeTableRepository :
        BaseRepository
            <CompanyStaffTimeTable, SmatimeDataset.CompanyStaffTimeTableDataTable, CompanyStaffTimeTableTableAdapter>
    {
        public IEnumerable<CompanyStaffTimeTable> GetCompanyStaffTimeTable(int storeId, int month)
        {
            using (var adapter = new CompanyStaffTimeTableTableAdapter())
            {
                using (var table = adapter.GetCompanyStaffTimeBy(month, storeId))
                {
                    var list = new List<CompanyStaffTimeTable>();
                    foreach (DataRow row in table.Rows)
                    {
                        var company = new CompanyStaffTimeTable();
                        company.FromDataRow(row);
                        list.Add(company);
                    }
                    return list;
                }
            }
        }
    }
}